/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sys.utils;

import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.ini4j.Ini;
import static sys.utils.ConexaoADS.section;
import static sys.utils.Utils.dirFileConfig;

/**
 *
 * @author Andrei
 */
public class ConexaoMySql {

    public static Connection getConection() throws SQLException {

        String server;
        String user;
        String senha;
        try {
            Ini ini = new Ini(new File(dirFileConfig()));
            server = ini.get(section, "server/ip");
            user = ini.get(section, "userMySQL");
            senha = ini.get(section, "senhaMySQL");

            Class.forName("com.mysql.jdbc.Driver");
            return DriverManager.getConnection("jdbc:mysql://" + server + "/vovo_joao", user, senha);
        } catch (ClassNotFoundException | IOException ex) {
            throw new SQLException(ex.getMessage());
        }
    }
}
